package com.xiefengf.rabbitmq.consumer.service;

import com.xiefengf.rabbitmq.consumer.utils.StringUtils;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xiefengf
 * @version 1.0
 * @date 2024/2/3 21:31
 *
 * 消息确认机制(事务+confirm)
 */
@Service
public class AckConsumerService {

    /**
     * 默认消费方式
     * @param msg
     */
    @RabbitListener(queues = {StringUtils.DIRECT_ACK_QUEUE_NAME_1})
    @RabbitHandler
    public void onMessage(@Payload String msg){
        // 此处省略发邮件的逻辑
        System.out.println("ack-----direct--------->" + msg);
    }


}
